package cn.cihon.ubi.qorosauto.dao.redis;

import java.util.HashMap;
import java.util.Iterator;
import java.util.UUID;

import redis.clients.jedis.Jedis;
import cn.cihon.ubi.qorosauto.bo.TripData;
import cn.cihon.ubi.qorosauto.util.DateUtil;
import cn.cihon.ubi.qorosauto.util.JedisUtil;

public class TripDataToRedis {
	
	
	private HashMap<String,String>  map =null;

	public void store(TripData tripdata,Jedis jedis)
	{
		String date = DateUtil.getDateStr(tripdata.getRecordTimestamp()) ;    //用于设置日期文件夹
		String VIN = tripdata.getVin();
		String time = DateUtil.DateToStr(tripdata.getRecordTimestamp());
		time = time.replaceAll(":", "-");
		System.out.println("redis 存储中记录时间：" + tripdata.getRecordTimestamp());
		map = tripdata.getMap();
		String str = date + ":" + VIN + ":" + time;
		jedis.select(8);                                     //选择数据库
		//jedis.hmset(str,map);                            //对数据库进行赋值
		//jedis.flushDB();                                 //删除当前数据库的所有内容
	/*	Iterator<String> iter=jedis.hkeys(str).iterator(); 
		while (iter.hasNext())
		{
			 String key = iter.next();  
			 jedis.hdel(str,key);
             System.out.println(key+":"+jedis.hdel(str,key));  
         }  
         */
		
	}
	
	public static void main(String[] args) {
		Jedis jedis = new Jedis("123.57.54.113", 6379);
		jedis.select(8);
		jedis.flushDB();
	}
	
}
